const mongoose = require('mongoose')
const dbUserName = 'blog'
const dbName = 'blog-db'
const dbPassword = '123456'
const dbHost = '127.0.0.1:27017'
// const dbConnectString = `mongodb://${dbUserName}:${dbPassword}@${dbHost}/${dbName}`
const dbConnectString = `mongodb://${dbHost}/${dbName}`
const mongoConnect = () => {
    mongoose.connect(dbConnectString, { useNewUrlParser: true})
        .then(() => {
            console.log('数据库连接成功')
        })
        .catch(err => {
            console.log('数据库连接失败', err)
        })
}
module.exports = mongoConnect
